package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.MemberSetmealDto;
import com.itheima.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/member")
public class MemberController {


    @Autowired
    private MemberService memberService;

    //用户端登录
    @PostMapping("/login")
    public Result login(@RequestBody MemberSetmealDto memberSetmealDto) {
        log.info("用户端登录，手机号：{}，验证码：{}", memberSetmealDto.getTelephone(), memberSetmealDto.getValidateCode());

        //登录
        memberService.login(memberSetmealDto);

        return new Result(true, MessageConstant.LOGIN_SUCCESS);
    }
}
